package com.suning.sawp.in.controller;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.suning.sawp.dto.common.EmployeeInfo;
import com.suning.sawp.dto.common.QueryResult;
import com.suning.sawp.dto.common.ReturnMsg;
import com.suning.sawp.dto.sys.LoginLogShowDto;
import com.suning.sawp.dto.sys.StoreManDeviceDto;
import com.suning.sawp.in.filter.RequestUserHolder;
import com.suning.sawp.intf.sys.SystemService;
import com.suning.vgs.follow.remote.store.StoreManDeviceParam;

@Controller
@RequestMapping("/adminPage/storeman")
public class StoreManDeviceController extends DjBaseController {
    
    @Resource
    SystemService systemService;
    
    /**
     * 
     * 功能描述: 查询设备绑定信息<br>
     * 〈功能详细描述〉
     *
     * @param regionCode
     * @param storeCode
     * @param bindStatus
     * @param pageNo
     * @param pageSize
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @RequestMapping("/queryBindDevices.do")
    public MyGsonView queryBindDevices(String regionCode, String storeCode
            , int bindStatus, String staffId, int pageNo, int pageSize) {
        StoreManDeviceParam deviceParam = new StoreManDeviceParam();
        deviceParam.setBindStatus(bindStatus);
        deviceParam.setRegionCode(regionCode);
        deviceParam.setStoreCode(storeCode);
        deviceParam.setStaffId(staffId);
        int startIndex = pageNo < 1 ? 0 : (pageNo - 1) * pageSize;
        deviceParam.setStartIndex(startIndex);
        deviceParam.setLimit(pageSize);
        
        ReturnMsg<QueryResult<StoreManDeviceDto>> retMsg = 
                systemService.queryStoreManDeviceInfo(deviceParam);
        
        return setGsonView(retMsg);
    }
    
    /**
     * 
     * 功能描述: 查询日志信息<br>
     * 〈功能详细描述〉
     *
     * @param pageNo
     * @param pageSize
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @RequestMapping("/queryLoginLogs.do")
    public MyGsonView queryLoginLogs(String staffId, int pageNo, int pageSize) {
        ReturnMsg<QueryResult<LoginLogShowDto>> returnMsg 
            = systemService.queryLoginLogs(staffId, pageSize, pageNo);
        
        return setGsonView(returnMsg);
    }
    
    /**
     * 
     * 功能描述: 解绑店员设备ID<br>
     * 〈功能详细描述〉
     *
     * @param staffId
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @RequestMapping("/unBindDevice.do")
    public MyGsonView unBindDevice(String staffId) {
        EmployeeInfo employeeInfo = RequestUserHolder.getRequestUser();
        ReturnMsg<String> returnMsg 
            = systemService.unBindDevice(staffId, employeeInfo.getStaffId());
        
        return setGsonView(returnMsg);
    }
    
    /**
     * 
     * 功能描述: 后台绑定设备ID<br>
     * 〈功能详细描述〉
     *
     * @param staffId
     * @param deviceName
     * @return
     * @see [相关类/方法](可选)
     * @since [产品/模块版本](可选)
     */
    @RequestMapping("/bindDevice.do")
    public MyGsonView bindDevice(String staffId) {
        EmployeeInfo employeeInfo = RequestUserHolder.getRequestUser();
        ReturnMsg<String> returnMsg 
            = systemService.bindDevice(staffId, employeeInfo.getStaffId(), employeeInfo.getStaffName());
        
        return setGsonView(returnMsg);
    }
    
}
